package com.synjones.pay.web.biz.recharge.helper;

import com.synjones.pay.model.recharge.RechargeReqBean;
import com.synjones.pay.model.recharge.RechargeRespBean;
import com.synjones.pay.web.biz.common.FailedVO;
import static com.synjones.pay.web.biz.common.PageParams.CLIENT_TYPE_WAP;
import com.synjones.pay.web.biz.common.WxRedisUserSnapBean;
import com.synjones.pay.web.biz.common.WxResponseBean;
import com.synjones.pay.web.biz.common.YktEaccInfoBean;

/**
 * 充值辅助类
 * @author sxj
 */
public class RechargeHelperBean {

    public static FailedVO getRechargeFailedVO(WxResponseBean respBean) {
        return new FailedVO(respBean.getErrCode(), respBean.getErrMsg());
    }

    public static FailedVO getChargeFailedVO(RechargeRespBean rrb) {
        if (rrb == null) 
            rrb = new RechargeRespBean();
        return new FailedVO(rrb.getStatusCode(), rrb.getStatusDesc(), rrb.getPaytoolCode(), rrb.getOrderId(), rrb.getCompleteTime());
    }
    
    public static RechargeReqBean getRechargeReqBean(WxResponseBean respBean,String appId,String device) {
        RechargeReqBean rrb = new RechargeReqBean();
        WxRedisUserSnapBean userInfo = respBean.getData().getUserInfo();
        rrb.setAppId(appId);
        rrb.setClientType(CLIENT_TYPE_WAP);//2代表wap,即微校
        rrb.setDevice(device);//设备信息从http中获取
        rrb.setUcode(userInfo.getSchoolCode());
        rrb.setUname(userInfo.getSchoolName());
        //TODO 目前限定给第一张卡的第一个电子账户充值
        YktEaccInfoBean eaccInfo = respBean.getData().getCardInfos().get(0).getEaccInfos().get(0);
        rrb.setRechargeAcc(eaccInfo.getType());
        rrb.setAccName(eaccInfo.getName());
        rrb.setRemark("电子账户充值");
        return rrb;
    }
}
